#include <iostream>
using namespace std;
class Base {
 public:
  Base() { cout << "Base()" << endl; }
  virtual ~Base() { cout << "~Base()" << endl; }
  void f1() { cout << "Base::f1()" << endl; }
  void f2() { cout << "Base::f2()" << endl; }
  virtual void f3() { cout << "virtual Base::f3()" << endl; }

 private:
};
class Derived : public Base {
 public:
  Derived() { cout << "Derived()" << endl; }
  ~Derived() { cout << "~Derived()" << endl; }

  void f1() { cout << "Derived::f1()" << endl; }  // 隐藏Base::f1()
  // 重载Base::f1()
  void f1(int t) { cout << "Derived::f1(int) " << t << endl; }
  void f3() { cout << "virtual Derived::f3()" << endl; }  // 重写Base::f3()

 private:
};
int main() {
  Base* bptr = new Derived;
  bptr->f1();
  bptr->f2();
  bptr->f3();
  delete bptr;
  cout << "-----------------" << endl;
  Derived d;
  d.f1();
  d.f1(5);
  d.f2();  // 继承自Base的成员
  d.f3();
  return 0;
}